﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using KouDai.Core.Service.Navigation;
using System.Collections.ObjectModel;
using KouDai.Core.Models;
using KouDai.Core.Engine;
using KouDai.Core.Service;

namespace KouDai.Core.ViewModel
{
    public class ImageWallItemsViewModel : NavigateViewModel
    {

        #region Fields
        private readonly INavigateService _navigateService;
        private ObservableCollection<HoneyEntity> _items = new ObservableCollection<HoneyEntity>();

        private long _minTimeStamp = 0;
        private long _maxTimeStamp = 0;

        #endregion

        #region Constructor
        public ImageWallItemsViewModel(INavigateService navigateService) :  base(navigateService)
        {
            _navigateService = navigateService;
        } 
        #endregion

        #region Properties
        public ObservableCollection<HoneyEntity> Items
        {
            get { return _items; }
            set { base.SetProperty(ref _items, value, () => this.Items); }
        }
        #endregion

        #region Override
        protected override void OnDataSet()
        {
            base.OnDataSet();
        }
        #endregion

        #region Method
        public async Task GetItems()
        {
            BackData backData = await KouDaiService.GetHotImageWall("Combine_Default", _minTimeStamp);
            List<HoneyEntity> honeyItems = (List<HoneyEntity>)backData.ResposeData;

            HoneyEntity lastEntity = honeyItems[honeyItems.Count - 1];
            this._minTimeStamp = lastEntity.Timestamp;

            honeyItems.ToObservableCollection(this.Items);
        }
        #endregion

    }
}
